<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<%@include file="/commons/commonList.jsp" %>

<script type="text/javascript">

    var currentBizModule="";
    var currentOperationType="";
    var OperationTypeArray=[];

	function init(){
		parent.window.document.all('otherPayBillList').style.height=document.body.scrollHeight;

	}

	function setCurrentId(id,BizModule,operationType){
	 currentBizModule=BizModule;
	 currentOperationType=operationType;
     parent.setcurrentRecordId(id);
	}

	function getChargeRecords(){
		var tableObj = document.getElementById("ec_table");
		var checkBoxArray = tableObj.getElementsByTagName("input");
		var selectedId = new Array();
		for(var i = 0; i < checkBoxArray.length; i++){
			if(checkBoxArray[i].type != "checkbox") continue;
			if(checkBoxArray[i].checked){
				selectedId[selectedId.length] = checkBoxArray[i].value;
			}
		}
		return selectedId.toString();
	}

	function getChargeSum(){
		var tableObj = document.getElementById("ec_table");
		var checkBoxArray = tableObj.getElementsByTagName("input");
		var selectedId = new Array();
		for(var i = 0; i < checkBoxArray.length; i++){
			if(checkBoxArray[i].type != "checkbox") continue;
			if(checkBoxArray[i].checked){
			checkBoxArray[i].onclick();
			}
		}

	}

	function checkbox(ojb,sum,operationType){


	       var isInArray=false;
           var OperationTypeCount=0;

	       for(var i=0;i<OperationTypeArray.length;i++){
                 var OperationTypeTemp1=OperationTypeArray[i].split("_");
	          if(OperationTypeTemp1[0]==operationType){
	             isInArray=true;
	             OperationTypeCount=Number(OperationTypeTemp1[1]);

	             break;
	           }

	        }

	    if(ojb.checked){//checkbox选中

           OperationTypeCount=OperationTypeCount+1;

	       if(isInArray){//已经在增加了，在原来的基础上加1

	          var OperationTypeArrayTemp02=[];

	           for(var n=0;n<OperationTypeArray.length;n++){
	            var OperationTypeTemp3=OperationTypeArray[n].split("_");
	               if(OperationTypeTemp3[0]!=operationType){
	               OperationTypeArrayTemp02[OperationTypeArrayTemp02.length]=OperationTypeArray[n];
	               }
	               if(OperationTypeTemp3[0]==operationType){

	                OperationTypeArrayTemp02[OperationTypeArrayTemp02.length]=operationType+"_"+OperationTypeCount;
	               }
	           }

	            OperationTypeArray=OperationTypeArrayTemp02;

	       }else{//每种类型第一次增加
	         OperationTypeArray[OperationTypeArray.length]=operationType+"_"+OperationTypeCount;
	       }

	    }else{//去除checkbox选中

	        if(isInArray){

	           var OperationTypeArrayTemp=[];

	           for(var m=0;m<OperationTypeArray.length;m++){
                  var OperationTypeTemp2=OperationTypeArray[m].split("_");
	               if(OperationTypeTemp2[0]!=operationType){
	               OperationTypeArrayTemp[OperationTypeArrayTemp.length]=OperationTypeArray[m];
	               }
	               if(OperationTypeTemp2[0]==operationType){
	                 OperationTypeCount=OperationTypeCount-1;
	                 if(OperationTypeCount!=0){
	                 OperationTypeArrayTemp[OperationTypeArrayTemp.length]=operationType+"_"+OperationTypeCount;
	                 }

	               }
	            }
               OperationTypeArray=OperationTypeArrayTemp;
             }
	    }

	    parent.setOperationTypeArray(OperationTypeArray);
        parent.deletePayModel();

        ///////////////////////////////////////////////////////////////////

	  if(ojb.checked){

       if(operationType=='001' || operationType=='004' || operationType=='005'){
	     parent.setSumCountAdd(sum);
	   }

		   var  chkbxNum= document.getElementsByName('keyword');
		   var chckHeader= true;

		   for (var i=0; i< chkbxNum.length; i++){
		     chckHeader= chckHeader && chkbxNum[i].checked;
		   }

		   if(chckHeader)document.getElementById('keyword_selector').checked = true;

		}else{

		if(operationType=='001' || operationType=='004' || operationType=='005'){
	     parent.setSumCountR(sum);
	    }

		 document.getElementById('keyword_selector').checked=false;
		}


	}

	function rightMenu(event){

		if(currentBizModule=='001'){

		  return false;
		}
		if(currentBizModule=='002'){
		  if(document.getElementById("quick_rightmenu_one")!=null){
		   document.getElementById('quick_rightmenu_one').style.display="";
		  }

		  if(document.getElementById("quick_rightmenu_two")!=null){
		   document.getElementById('quick_rightmenu_two').style.display="none";
		  }
		}
		if(currentBizModule=='003'){
		  if(document.getElementById("quick_rightmenu_two")!=null){
		    document.getElementById('quick_rightmenu_two').style.display="";
		   }

		  if(document.getElementById("quick_rightmenu_one")!=null){
		    document.getElementById('quick_rightmenu_one').style.display="none";
		  }
		}

	 ShowContextMenu(event,'quick_rightmenu');

	}

	function checkboxAll(){

	   var tableObj = document.getElementById("ec_table");
		var checkBoxArray = tableObj.getElementsByTagName("input");
		var selectedId = new Array();
		for(var i = 0; i < checkBoxArray.length; i++){
			if(checkBoxArray[i].type != "checkbox") continue;
          if(checkBoxArray[i].disabled)continue;
           if(checkBoxArray[i].checked){
              if(document.getElementById('keyword_selector').checked){
              continue;
              }
           }

			checkBoxArray[i].checked=document.getElementById('keyword_selector').checked;
			checkBoxArray[i].onclick();


		}


	}



</script>
</head>
<body onload="init();">
<div style="height:230px;overflow:auto;">
	<ec:ceTable items="otherPayBillList"
			autoIncludeParameters="true"
			var="chargeItemItem"
			action="{ctx}/charge_cashieringAction.do?method=otherPayBillList"
			rowsDisplayed="${totalRows}"
			width="100%"
			view="pmsNoPageView"
			styleClass="gridData"
			>
			<ec:ceRow styleClass="grid" onclick="setCurrentId('${chargeItemItem.keyword}','${chargeItemItem.bizModule}','${chargeItemItem.operationType}');" ondblclick="return false"
			onContextMenu="return rightMenu(event);">
				<ec:ceColumn showTitle="false" headerCell="checkboxHeader"  property="keyword" sortable="false" width="5%">
<input type="checkbox"  name="keyword"  value="${chargeItemItem.keyword}"  onclick="checkbox(this,'${chargeItemItem.sum}','${chargeItemItem.operationType}');" ${chargeItemItem.operationType=='003'?'checked':''} ${chargeItemItem.operationType=='003'?'disabled':''}>
				</ec:ceColumn>
				<ec:ceColumn headerCell="pmsHeadrCell" width="15%" property="bizModule" title="业务类型">
				<c:if test="${chargeItemItem.bizType=='001'}">装修许可收费</c:if>
			    <c:if test="${chargeItemItem.bizType=='002'}">装修出入证收费</c:if>
				<c:if test="${chargeItemItem.bizType=='003'}">装修出入证退费</c:if>
				<c:if test="${chargeItemItem.bizType=='004'}">装修保证金核算</c:if>
			    <c:if test="${chargeItemItem.bizType=='005'}">客服派工收费</c:if>
				<c:if test="${chargeItemItem.bizType=='006'}">入伙收费</c:if>
				</ec:ceColumn>
				<ec:ceColumn headerCell="pmsHeadrCell" width="15%" property="itemName" title="收费项目"></ec:ceColumn>
				<ec:ceColumn headerCell="pmsHeadrCell" width="15%" property="sum" title="收款金额"></ec:ceColumn>
				<ec:ceColumn headerCell="pmsHeadrCell" width="15%" property="#" title="操作日期">
					<fmt:formatDate pattern="yyyy-MM-dd" value="${chargeItemItem.sysDate }"/>
				</ec:ceColumn>
				<ec:ceColumn headerCell="pmsHeadrCell" width="10%" property="operatorName" title="操作人"></ec:ceColumn>
				<ec:ceColumn headerCell="pmsHeadrCell" width="22%" property="remark" title="备 注"></ec:ceColumn>

			</ec:ceRow>
	</ec:ceTable>

</div>
<div id="quick_rightmenu" style="display:none;"  oncontextmenu="return false" class="quick_rightmenu"onMouseOver="MM_showHideLayers('quick_rightmenu')"  onMouseOut="MM_showHideLayers('quick_rightmenu')">
<table width="100%" border="0" cellpadding="1" cellspacing="0" class="grid_quickMenu_bg">

	<tr>
      <td><table width="100%" border="0" cellpadding="2" cellspacing="0">
        <tr id="quick_rightmenu_one">
          <td class="quickMenu_toolbarico"><a href="#"  onclick="parent.monthBalance();return false;" onfocus="this.blur()"><img src="${ctx}/images/ico_jiesuan.gif" border="0" align="absbottom" alt=""/> 月末结算</a></td>
          </tr>
           <tr id="quick_rightmenu_two">

          <td class="quickMenu_toolbarico"><a href="#"  onclick="parent.deleteAsk();return false;" onfocus="this.blur()"><img src="${ctx}/images/ico_delete.gif" border="0" align="absbottom" alt=""/>&nbsp;删除</a></td>
          </tr>

      </table></td>
    </tr>
  </table>
<script type="text/javascript">

	var div1=document.getElementById('quick_rightmenu');
	if(div1.getElementsByTagName("tr").length==2){
	div1.innerHTML="";
	}


</script>
</div>

</body>
<script type="text/javascript">
document.getElementById("keyword_selector").onclick=checkboxAll;
parent.initSumCount();
getChargeSum();
</script>
</html>